package chen.huai.jie.spring.xmlconfig.mybatis;

import java.util.List;

public class Page<E> {
    private long total;
    private int current;
    private int size;
    private List<E> content;

    public Page() {
    }

    public Page(List<E> content, long total, int page, int size) {
        this.content = content;
        this.total = total;
        this.current = page;
        this.size = size;
    }

    public static <Content> Page<Content> from(List<Content> content, PageRequest request) {
        return new Page(content, request.context, request.getCurrent(), request.getSize());
    }

    public long getTotal() {
        return this.total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public int getCurrent() {
        return this.current;
    }

    public void setCurrent(int current) {
        this.current = current;
    }

    public int getSize() {
        return this.size;
    }

    public void setSize(int size) {
        this.size = size;
    }

    public List<E> getContent() {
        return this.content;
    }

    public void setContent(List<E> content) {
        this.content = content;
    }

    @Override
    public String toString() {
        return "Page{" +
                "total=" + total +
                ", current=" + current +
                ", size=" + size +
                ", content=" + content +
                '}';
    }
}
